<template>
    <div>
        <showcate  :data='catelist' :cid='course.cid' @cid='getcid'/>
        <van-field v-model="course.name" label="名称" />
        <van-field v-model="course.description" label="描述" />
        <van-field v-model="course.tname" label="讲师" />
        <van-image :src='course.pic' width=100 height=100 />
        <video :src='"http://localhost:5000/static/upload/"+i' controls="controls" v-for='i in videos' width=300 height=200></video>
        <br>
        <van-button @click='update'>修改</van-button>

    </div>
</template>

<script>
import showcate from './showcate.vue'
    export default {
        components:{
            'showcate':showcate,
            
            
        },
        data(){
            return{
                catelist:[],
                id:this.$route.query.id,
                course:{'name':''},
                videos:[]

            }
        },
        methods: {
              //获取所有分类信息
        getCatelist(){
            this.$axios.get('lianxi/showcate/').then(res=>{
                    this.catelist =res.data.list
                })
        },
        getcourse(){
            this.$axios.get('lianxi/courseM/?id='+this.id).then(res=>{
                this.course = res.data.course
                //把视频列表转换成json
                this.videos = JSON.parse(res.data.course['vedios'])
            })
        },
        getcid(id){
            alert(id)
        },
        update(){

        }
        },
        mounted() {
            this.getCatelist()
        },
        mounted() {
        this.getcourse()
        this.getCatelist()
    },

    }
</script>

<style scoped>

</style>